Skip to content

fix: update torch.amp.autocast to use modern API#349

Closed
fchange wants to merge 1 commit intoInterDigitalInc:masterfrom
fchange:claude/fix-torch-autocast-deprecation-01XVXyqnK3SMWnDi1Scr8VKb
Closed

fix: update torch.amp.autocast to use modern API#349
fchange wants to merge 1 commit intoInterDigitalInc:masterfrom
fchange:claude/fix-torch-autocast-deprecation-01XVXyqnK3SMWnDi1Scr8VKb

Conversation

@fchange
Copy link

@fchange fchange commented Nov 19, 2025

Replace deprecated device_type parameter usage with positional argument in amp.autocast calls to fix FutureWarning:

  • compressai/models/video/google.py:362
  • compressai/utils/video/eval_model/main.py:373

Changed from:
amp.autocast(device_type=device.type, enabled=...) To:
amp.autocast(device.type, enabled=...)

This uses the modern torch.amp.autocast API and improves compatibility with various device types including potential future CANN/NPU support.

Replace deprecated device_type parameter usage with positional argument
in amp.autocast calls to fix FutureWarning:
- compressai/models/video/google.py:362
- compressai/utils/video/eval_model/__main__.py:373

Changed from:
  amp.autocast(device_type=device.type, enabled=...)
To:
  amp.autocast(device.type, enabled=...)

This uses the modern torch.amp.autocast API and improves compatibility
with various device types including potential future CANN/NPU support.
@fracape fracape self-requested a review March 10, 2026 23:13
@fracape fracape self-assigned this Mar 10, 2026
@fracape
Copy link
Collaborator

fracape commented Mar 11, 2026

Does not seem to be a problem. autocast still use device_type

@fracape fracape closed this Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants